package ar.com.drinkLabs.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import ar.com.drinkLabs.R;
import ar.com.drinkLabs.components.ImageCell;

public class ImageAdapter extends BaseAdapter {
    private Context mContext;

    public ImageAdapter(Context c) {
        mContext = c;
    }

    public int getCount() {
        return mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(120, 120));
            imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(((ImageCell)mThumbIds[position]).getImageId());
        imageView.setAdjustViewBounds(true);
        imageView.setMaxHeight(100);
        imageView.setMaxWidth(100);
        return imageView;
    }

    // references to our images
    public ImageCell[] mThumbIds = {
            new ImageCell(R.drawable.uno,1), new ImageCell(R.drawable.dos,2) ,
            new ImageCell(R.drawable.tres,3), new ImageCell(R.drawable.cinco,5),
            new ImageCell(R.drawable.ocho,8),new ImageCell(R.drawable.trece,13) ,
            new ImageCell(R.drawable.veinte,20),new ImageCell(R.drawable.nose,0) ,
            new ImageCell(R.drawable.infinito,0)
    };
}